<!--<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">-->
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
	<title>天天生鲜-登录</title>
	<link rel="stylesheet" type="text/css" href="/css/reset.css">
	<link rel="stylesheet" type="text/css" href="/css/main.css">
	<script src="/js/jquery-1.12.4.min.js"></script>

</head>
<body>
	<div class="login_top clearfix">
		<a href="index.html" class="login_logo"><img src="/images/logo02.png"></a>
	</div>

	<div class="login_form_bg">
		<div class="login_form_wrap clearfix">
			<div class="login_banner fl"></div>
			<div class="slogan fl">日夜兼程 · 急速送达</div>
			<div class="login_form fr">
				<div class="login_title clearfix">
					<h1>用户登录</h1>
					<a href="/user/backregister">立即注册</a>
				</div>
				<div class="form_input">
					<form id="formInfo">
						<input type="text" name="username" class="name_input" placeholder="请输入用户名" id="username" onblur="checkname2()" >
						<div class="user_error">输入错误</div>
						<input type="password" name="password" class="pass_input" placeholder="请输入密码" id="password" onblur="checkpassword()">
						<div class="pwd_error">输入错误</div>
						<div class="more_input clearfix">
							<input type="checkbox" name="remember">
							<label>记住用户名</label>
							<a href="#">忘记密码</a>
						</div>
						<input type="button" name="" value="登录" class="input_submit" onclick="senddata()">
					</form>
				</div>
			</div>
		</div>
	</div>

	<div class="footer no-mp">
		<div class="foot_link">
			<a href="#">关于我们</a>
			<span>|</span>
			<a href="#">联系我们</a>
			<span>|</span>
			<a href="#">招聘人才</a>
			<span>|</span>
			<a href="#">友情链接</a>		
		</div>
		<p>CopyRight © 2016 北京天天生鲜信息技术有限公司 All Rights Reserved</p>
		<p>电话：010-****888    京ICP备*******8号</p>
	</div>

<script type="text/javascript">

	function checkname2() {
        var username=$("#username").val();
        if (username==""){
            $(".user_error").show();
            username=false;
        } else {
            $(".user_error").hide();
            username=true;
        }
    }

    function checkpassword() {
        var password=$("#password").val();
        if (password==""){
            $(".pwd_error").show();
            password=false;
        } else {
            $(".pwd_error").hide();
            password=true;
        }
    }



    function senddata() {
        if (username&&password){
            var info=$("#formInfo").serialize();
            console.log(info)
            $.ajax({
                url:"/user/tologin",
                data:info,
                type:"post",
                datatype:"json",
                success:function (result) {
                    if (result.code==0){
						alert("登录成功")
                        location.href="/user/index"
                    } else {
                        $(".pwd_error").html(result.msg).show()
                    }
                },
                error:function () {
                    $(".pwd_error").html("数据回传错误 请联系管理员").show()
                }
            })
    }


	}




</script>
	
</body>
</html>